<HTML><HEAD><TITLE>open_tagged_receiver(+Tag, +SendPort, ?ReceivePort)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(notify_ports)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>open_tagged_receiver(+Tag, +SendPort, ?ReceivePort)</H1>
Create a receiver for one or more tagging senders
<DL>
<DT><EM>Tag</EM></DT>
<DD>an arbitrary term
</DD>
<DT><EM>SendPort</EM></DT>
<DD>a tagged-send-port structure
</DD>
<DT><EM>ReceivePort</EM></DT>
<DD>a tagged-receive-port structure or a variable
</DD>
</DL>
<H2>Description</H2>

    This predicate either creates a new receive port and connects it to an
    existing tagged-send port, or connects an existing receive port to an
    additional existing tagged-send port.  The new receive port will receive
    all messages that are sent via the send port after the receiver
    has been opened.  Any messages that were sent before the receiver was
    opened will not be received by this receiver.
    </P><P>
    Messages that arrive on ReceivePort from SendPort will get tagged with
    Tag, i.e. the received message will be a structure of the form
    <PRE>
    	Tag : Message
    </PRE>
    If several senders are connected to ReceivePort, the tag can thus
    be used to identify the origin of the message.
    </P>
    
<H3>Modes and Determinism</H3><UL>
<LI>open_tagged_receiver(+, +, -)
<LI>open_tagged_receiver(+, +, +)
</UL>
<H2>Examples</H2>
<PRE>
    ?-	open_tagging_sender(S1),
	open_tagging_sender(S2),
	open_tagged_receiver(r1s1, S1, R1),
	open_tagged_receiver(r1s2, S2, R1),
	open_tagged_receiver(r2s1, S1, R2),
	open_tagged_receiver(r2s2, S2, R2),

	send_notification(S1, m1),
	send_notification(S1, m2),
	send_notification(S2, m3),
	send_notification(S1, m4),
	send_notification(S2, m5),

	receive_notifications(R1, R1M1, _),
	receive_notifications(R2, R2M1, _).

    ...
    R1M1 = [r1s1 : m1, r1s1 : m2, r1s2 : m3, r1s1 : m4, r1s2 : m5]
    R2M1 = [r2s1 : m1, r2s1 : m2, r2s2 : m3, r2s1 : m4, r2s2 : m5]
    Yes (0.00s cpu)
    </PRE>
<H2>See Also</H2>
<A HREF="../../lib/notify_ports/open_tagging_sender-1.html">open_tagging_sender / 1</A>, <A HREF="../../lib/notify_ports/send_notification-2.html">send_notification / 2</A>, <A HREF="../../lib/notify_ports/receive_notifications-3.html">receive_notifications / 3</A>, <A HREF="../../lib/notify_ports/foreachnotification-6.html">foreachnotification / 6</A>
</BODY></HTML>
